package com.easychat.controller;

import com.easychat.annotation.GlobalInterceptor;
import com.easychat.entity.po.UserInfoBeauty;
import com.easychat.entity.query.UserInfoBeautyQuery;
import com.easychat.entity.vo.PaginationResultVO;
import com.easychat.entity.vo.ResponseVO;
import com.easychat.service.UserInfoBeautyService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * @Author: yudaxian
 * @Description: TODO
 * @DateTime: 2024/8/16 10:43
 **/
@RestController
@RequestMapping("/admin")
public class AdminUserInfoBeautyController extends ABaseController {

    @Resource
    private UserInfoBeautyService userInfoBeautyService;

    @GlobalInterceptor
    @RequestMapping("/loadBeautyAccountList")
    public ResponseVO loadBeautyAccountList(HttpServletRequest request, @NotEmpty Integer pageNo) {

        UserInfoBeautyQuery query = new UserInfoBeautyQuery();
        query.setPageNo(pageNo);
        PaginationResultVO<UserInfoBeauty> list = userInfoBeautyService.findListByPage(query);

        return getSuccessResponseVO(list);
    }

    @GlobalInterceptor
    @RequestMapping("/saveBeautAccount")
    public ResponseVO saveBeautAccount(HttpServletRequest request,
                                       @NotNull UserInfoBeauty userInfoBeauty
    ) {
        userInfoBeautyService.saveBeautyAccount(userInfoBeauty);
        return getSuccessResponseVO(null);
    }

    @GlobalInterceptor
    @RequestMapping("/delBeautAccount")
    public ResponseVO delBeautAccount(HttpServletRequest request,
                                       @NotNull String id
    ) {
        userInfoBeautyService.deleteUserInfoBeautyById(Integer.valueOf(id));
        return getSuccessResponseVO(null);
    }

}
